# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=daredevil
pkgver=42.81cb57f
pkgrel=1
pkgdesc='A tool to perform (higher-order) correlation power analysis attacks (CPA).'
groups=('blackarch' 'blackarch-crypto')
arch=('x86_64' 'aarch64')
url='https://github.com/SideChannelMarvels/Daredevil'
license=('GPL3')
depends=('openmp')
makedepends=('git' 'clang')
source=("$pkgname::git+https://github.com/SideChannelMarvels/Daredevil.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
  cd $pkgname

  make
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  cp -a LUT CONFIG "$pkgdir/usr/share/$pkgname/"

  install -Dm 755 $pkgname "$pkgdir/usr/share/$pkgname/$pkgname"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec ./$pkgname "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

